#!/bin/zsh
plistFile="$1"

if [[ ! -e "${plistFile}" ]]; then
	echo "auto increase build,but no info plist file found!"
	exit -1
fi



# 读取Build版本号
buildNumber=$(/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "${plistFile}")
if [[ "${buildNumber}" == "\$(CURRENT_PROJECT_VERSION)" ]]; then
	buildNumber=${CURRENT_PROJECT_VERSION}
fi
echo "previous build number is: ${buildNumber}"

buildNumber=$((++buildNumber))
echo "current build number is: ${buildNumber}"

# 设置Build版本号
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${plistFile}"



